<template>
  <div class="nav">
    <p>开发者查询</p>
    <div>
      <input
      ref="searchInput"
        type="text"
        placeholder="请输入搜索关键词"
        v-model="searchWord"
        @focus="changeInputFocusStyle"
        @blur="changeInputBlurStyle"
        @keydown="goSearch"
      /><i @click="searchForWord">搜索</i>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchWord: "",
    };
  },
  mounted(){
    this.$refs.searchInput.focus()
  },
  methods: {
    goSearch(e){
      e.keyCode===13&&this.searchForWord()
    },
    searchForWord(){
        let a = document.createElement('a')
        a.href = "https://kaifa.baidu.com/searchPage?wd="+this.searchWord
        a.target = "_blank"
        a.click()

    }
  },
};
</script>

<style lang="less" scoped>
.nav {
  p {
    text-align: center;
    font-size: 20px;
    color: #00000099;
    margin-bottom: 10px;
  }
  i {
    opacity: 0.8;
    display: inline-block;
    background-color: #5568de;
    width: 70px;
    height: 44px;
    vertical-align: top;
    line-height: 40px;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    color: #fff;
    transition: all 0.3s;
    &:hover {
      background-color: lighten(#5568de, 5%);
    }
  }
  div {
    text-align: center;
    input {
      opacity: 0.8;
      border-left: 2px solid #c5c7ce;
      border-top: 2px solid #c5c7ce;
      border-bottom: 2px solid #c5c7ce;
      border-right: none;
      width: 40%;
      height: 40px;
      border-top-left-radius: 10px;
      border-bottom-left-radius: 10px;
      padding: 0 10px;
      transition: all 0.3s;
      &:hover {
        border-left: 2px solid #5568de;
        border-top: 2px solid #5568de;
        border-bottom: 2px solid #5568de;
      }
    }
  }
}
</style>